/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hotelinteligente.vista;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;

/**
 *
 * @author vero
 */
public class DispositivoDibujable implements Dibujable {

    private String id;
    private Image imagen;
    private Font font;
    private boolean dibujar;
    int x,y;

    public DispositivoDibujable(String deviceId, String ruta, int x, int y) {
        this.id= deviceId;
        this.x= x;
        this.y= y;
        font= new Font(Font.DIALOG, Font.BOLD, 14);
        this.dibujar= false;
        this.imagen= java.awt.Toolkit.getDefaultToolkit().getImage(getClass().getResource(ruta));
    }

    @Override
    public void draw(Graphics g) {
        if(dibujar) {
            g.drawImage(imagen, x, y, null);
            g.setFont(font);
            g.setColor(Color.BLACK);
            g.drawString(id, x-20, y);
        }
    }

    public String getDeviceId() {
        return this.id;
    }

    public int getX() {
        return this.x;
    }

    public int getY() {
        return this.y;
    }

    public void setPosition(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public boolean isSelected(int x, int y) {
        /*if(imagen != null) {
            if(imagen.contains(x, y))
                return true;
         }*/
         return false;
    }

    public boolean getDibujar() {
        return dibujar;
    }

    public void dibujar() {
        dibujar= true;
    }

    public void no_dibujar() {
        dibujar= false;
    }
}
